package cn.edu.dz.ld;

public class Soldier {
    //定义属性，姓名
    private String name;
    //使用武器
    private Weapon weapon;

    public Soldier() {
    }

    public Soldier(String name, Weapon weapon) {
        this.name = name;
        this.weapon = weapon;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
    public String getWeapon(Weapon weapon){
        this.weapon=weapon;
        weapon.kill();
        return this.name+"得到的武器"+ this.weapon;
    }

    @Override
    public String toString() {
        return "Soldier{" +
                "name='" + name + '\'' +
                ", weapon=" + weapon +
                '}';
    }
}
